import com.cn.Mapper.userMapper.UserMapper;
import com.cn.entity.user.User;
import com.cn.util.SqlsesstionUtil;
import org.apache.ibatis.session.SqlSession;
import org.junit.Test;

import java.util.List;

/**
 * @ClassName test01
 * @Description TODO
 * @Author yujiajing
 * @Date 2022/9/30 21:57
 * @Version 1.0
 */

public class testUser {
    @Test
    public void insertUser() {
        SqlSession sqlSession = SqlsesstionUtil.getSqlSession();
        UserMapper userMapper = sqlSession.getMapper(UserMapper.class);
        User user=new User("4","cxk","3365");
        userMapper.insertUser(user);
    }

    @Test
    public void SelectUser() {
        SqlSession sqlSession = SqlsesstionUtil.getSqlSession();
        UserMapper userMapper = sqlSession.getMapper(UserMapper.class);
        List<User> userLinkedList = userMapper.selectAllUser();
        for (User user : userLinkedList) {
            System.out.println(user.toString());
        }

    }

    @Test
    public void deleteUser() {
        SqlSession sqlSession = SqlsesstionUtil.getSqlSession();
        UserMapper userMapper = sqlSession.getMapper(UserMapper.class);
        userMapper.deleteUser("1");
    }

    @Test
    public void updateUser() {
        SqlSession sqlSession = SqlsesstionUtil.getSqlSession();
        UserMapper userMapper = sqlSession.getMapper(UserMapper.class);
        userMapper.updateUser("小红", "1239", "2");
    }

    @Test
    public void checkLogin() {
        SqlSession sqlSession = SqlsesstionUtil.getSqlSession();
        UserMapper userMapper = sqlSession.getMapper(UserMapper.class);
        if (userMapper.checkLogin("pop", "12366") != null) {
            System.out.println("登录成功");

        }
    }
}
